from typing import List


class Solution:
    def dailyTemperatures(self, T: List[int]) -> List[int]:
        max = 0
        res = [0 for i in range(0, len(T))]
        for i in range(len(T)-1, -1, -1):
            max = max if max > T[i] else T[i]

            if(T[i] == max):
                res[i] = 0
            else:
                for j in range(i, len(T)):
                    if(T[i] < T[j]):
                        res[i] = j-i
                        break
        return res


if __name__ == "__main__":
    print(Solution().dailyTemperatures([73, 74, 75, 71, 69, 72, 76, 73]))
